/*
 * @Autor: 陈锦
 * @Date: 2021-05-25 08:46:05
 * @LastEditors: 夏潇洋 70366026@qq.com
 * @LastEditTime: 2022-06-16 09:47:14
 * @Description: 红星闪闪
 */
// 后端接口********************后端接口********************后端接口********************后端接口********************
import request from '@/common/request/request.config.js';
import { uploadFile } from '@/common/request/API.js';
import { baseUrl } from "./config";
import store from '@/store/index';
// export const baseUrl = store.state.baseUrl;

// import { request3 } from '@/common/request/req.js';
// import Vue from 'vue';
// let baseUrl = Vue.prototype.$store.state.token;
// let baseUrl = 'https://192.168.124.103:10002';
// 封装好post请求
const post = (URL, params = {}) => {
    return new Promise((resolve, reject) => {
        request
            .post(URL, {
                data: params,
            })
            .then(res => {
                resolve(res);
            })
            .catch(err => {
                reject(err);
            })
            .finally(res => {
                resolve(res);
            });
    });
};
// 获取当前日期的年、月、日
const now = new Date();

const year = now.getFullYear(); // 获取当前年份
const month = now.getMonth() + 1; // 获取当前月份，getMonth() 返回的月份从0开始，所以需要加1
const day = now.getDate(); // 获取当前日

// 将月份和日期格式化为两位数
const formattedMonth = month.toString().padStart(2, '0');
const formattedDay = day.toString().padStart(2, '0');

// 组合成 YYYY-MM-DD 格式
const currentDate = `${year}-${formattedMonth}-${formattedDay}`;

// 封装好get请求-----------------无参数
const get  = (URL) => {
	request.config.header.Authorization = 'Bearer ' + uni.getStorageSync('token')
	let pageDate = localStorage.getItem('pageDate') ? localStorage.getItem('pageDate') : currentDate;  //缓存时间
	let cityName = localStorage.getItem('cityName') ? localStorage.getItem('cityName') : '';  //地市
    return new Promise((resolve, reject) => {
        request
            .get(
				URL + '?dutydate=' + pageDate  + '&city=' + cityName
            )
            .then(res => {
                resolve(res);
            })
            .catch(err => {
                reject(err);
            })
            .finally(res => {
                resolve(res);
            });
    });
};
// 封装好getp请求-----------------有参数
const getp = (URL, params) => {
	request.config.header.Authorization = 'Bearer ' + uni.getStorageSync('token')
	let pageDate = localStorage.getItem('pageDate') ? localStorage.getItem('pageDate') : currentDate;  //缓存时间
	let cityName = localStorage.getItem('cityName') ? localStorage.getItem('cityName') : '';  //地市
    return new Promise((resolve, reject) => {
		 
        request
            .get(
                URL + params + '&dutydate=' + pageDate + '&city=' + cityName
            )
            .then(res => {
                resolve(res);
            })
            .catch(err => {
                reject(err);
            })
            .finally(res => {
                resolve(res);
            });
    });
};
// 以下是接口请求的api*********************************************************************************************
export const API = {
    // 1.测试
    // getTest: params => {
    //     return getp('/homeService/api/informationRelease/selectClassCount', params);
    // },
    // 1.获取验证码
    // http://111.48.251.140:10002/api/Login/getcheckcode
    //  http://yeyang-PC:8033/api/Login/getcheckcode 
    // http://192.168.1.100:8033/api/Login/getcheckcode
    // http://120.202.250.92:10005/api/Login/getcheckcode
    // http://192.168.1.104:10652/api/Login/getcheckcode
	// 获取阿里云token
    getAliToken: () => {
        return get('/api/v1.0/gettoken');
    },
	//获取手机号
	getphonen: params => {
	    return getp('/phoneapi/v1.0/getphone', params);
	},
    // 1.登录
    login: params => {
        return post('/api/Login/logincheck', params);
    },
	// 2.手机号免密登录
	gettokenbyphone: params => {
	    return getp('/phoneapi/v1.0/gettokenbyphone', params);
	},
    // 3.获取当前用户标签权限
	getpermission: () => {
	    return getp('/api/v1.0/asset/getpermission',params);
	},
	//---------------------------------概览------------------------------------
	
	//首页重点关注
	getexecData: params => {
	    return get('/api/v1.0/malfunctioncity/getexecData');
	},
	//故障专题
	getmalData: params => {
	    return get('/api/v1.0/malfunctioncity/getmalData');
	},
	//投诉专题
	getcomData: params => {
	    return get('/api/v1.0/malfunctioncity/getcomData');
	},
	//业务专题
	getyxzwData: params => {
	    return get('/api/v1.0/malfunctioncity/getyxzwData');
	},
	//网络满意度
	getwlmydData: params => {
	    return get('/api/v1.0/malfunctioncity/getwlmydData');
	},
	//统计周期
	gettjzqData: params => {
	    return get('/api/v1.0/malfunctioncity/gettjzqData');
	},
	//获取地市
	getusercity: params => {
	    return get('/api/v1.0/common/getusercity');
	},
	
	//---------------------------------通讯录------------------------------------
	//查询通讯录信息
	getmailList: params => {
	    return getp('/api/v1.0/malfunction/getmailList', params);
	},
	//---------------------------------日志------------------------------------
	getlogList: params => {
	    return get('/api/v1.0/common/getlogList');
	},
	//---------------------------------故障tab1------------------------------------
	// 故障 - 集团重大故障明细
	getjtList: params => {
	    return get('/api/v1.0/malfunctioncity/getjtList');
	},
	// 故障 - 集团重大故障预警明细
	getjtwarnList: params => {
	    return get('/api/v1.0/malfunctioncity/getjtwarnList');
	},
	// 故障 - 省内重大故障明细
	getsnList: params => {
	    return get('/api/v1.0/malfunctioncity/getsnList');
	},
	// 故障 - 省内重保故障明细
	getsnzbList: params => {
	    return getp('/api/v1.0/malfunctioncity/getsnzbList', params);
	},
	// 故障 - 地市工单情况-柱图
	getworkcityData: params => {
	    return getp('/api/v1.0/malfunctioncity/getworkCountyList',params);
	},
	// 故障 - 事件平均历时（地市）
	getEventCityList: params => {
	    return get('/api/v1.0/malfunctioncity/getEventCountyList');
	},
	// 故障 - 定界定位失败站点数（地市）
	getPosiCityList: params => {
	    return get('/api/v1.0/malfunction/getPosiCityList');
	},
	// 故障-省内隐患（地市）
	getsnyhCityList: params => {
	    return get('/api/v1.0/malfunctioncity/getsnyhCountyList');
	},
	// 故障-全网故障情况（全省）
	getmalCityData: params => {
	    return get('/api/v1.0/malfunctioncity/getmalCityData');
	},
	//故障-定界定位告警关联
	getposiCountyList: params => {
	    return get('/api/v1.0/malfunctioncity/getposiCountyList');
	},
	//故障-隐患超时工单数
	gethiddenCountyList: params => {
	    return get('/api/v1.0/malfunctioncity/gethiddenCountyList');
	},
	//---------------------------------故障tab2------------------------------------
	//无线实时退服
	getwirelessData: params => {
	    return get('/api/v1.0/malfunctioncity/getwirelessData');
	},
	//无线实时退服（地市）
	getwxcityData: params => {
	    return getp('/api/v1.0/malfunctioncity/getwxcountyData', params);
	},
	// 加宽 - 家宽OLT
	getoltData: params => {
	    return get('/api/v1.0/malfunctioncity/getoltData');
	},
	//汇聚机房停电
	getpowerfailData: params => {
	    return get('/api/v1.0/malfunctioncity/getpowerfailData');
	},
	//累计实时退服（地市）
	getwxallcityData: params => {
	    return getp('/api/v1.0/malfunction/getwxallcityData', params);
	},
	//无线累计退服（区县）
	getwxallcountyData: params => {
	    return getp('/api/v1.0/malfunction/getwxallcountyData', params);
	},
	//故障OLT退服（折线图）
	getoltcityData: params => {
	    return get('/api/v1.0/malfunctioncity/getoltcountyData');
	},
	//汇聚机房停电（折线图）
	getpowerCityList: params => {
	    return get('/api/v1.0/malfunctioncity/getpowerCountyList');
	},

	//---------------------------------投诉------------------------------------
	// 概览 - 投诉
	getDataGKTS: params => {
	    return get('/api/v1.0/complaintcity/getData');
	},
	//投诉 - 详情
	getComplaintListDataTS: params => {
	    return getp('/api/v1.0/complaintcity/getcomplaintList', params);
	},
	// 投诉 - 查询5G行业投诉明细
	get5gListTS: params => {
	    return get('/api/v1.0/complaintcity/get5gList');
	},
	// 投诉 - 查询政企专线投诉明细
	getgovListTS: params => {
	    return get('/api/v1.0/complaintcity/getgovList');
	},
	// 投诉 - 查询物联网投诉明细
	getiotListTS: params => {
	    return get('/api/v1.0/complaintcity/getiotList');
	},
	// 投诉 - 专线中断
	getlineListTS: params => {
	    return get('/api/v1.0/complaintcity/getlineList');
	},
	//---------------------------------割接------------------------------------
	//查询每日割接情况
	getcutoverData: params => {
	    return getp('/api/v1.0/cutovercity/getcutoverData', params);
	},
	//查询每日割接情况
	getcutoverInfo: params => {
	    return getp('/api/v1.0/cutovercity/getcutoverInfo', params);
	},
	//---------------------------------指标------------------------------------
	//指标地市业务规模
	getbuscityData: params => {
	    return get('/api/v1.0/index/getbuscityData');
	},
	//指标移动业务 政企
	getydywcityData: params => {
	    return get('/api/v1.0/index/getydywcityData');
	},
	//指标固定上网
	getgdswcityData: params => {
	    return getp('/api/v1.0/index/getgdswcityData', params);
	},
	//查询IDC明细数据
	getidcList: params => {
	    return get('/api/v1.0/index/getidcList');
	},
	//询无线网地市数据
	getwxcityDataZB: params => {
	    return get('/api/v1.0/index/getwxcityData');
	},
	//家客装机运维信息
	getjiakeCityData: params => {
	    return get('/api/v1.0/index/getjiakeCityData');
	},
	//集客装机运维信息
	getjikeCityData: params => {
	    return get('/api/v1.0/index/getjikeCityData');
	},
	// 业务-有线装维（家客）
	getjiakeInfo: params => {
		return get('/api/v1.0/indexcity/getjiakeData')
	},
	// 业务-有线装维（集客）
	getjikeInfo: params => {
		return get('/api/v1.0/indexcity/getjikeData')
	},
	// 业务-有线装维（家客） 柱图数据
	getjiakeCityInfo: params => {
		return getp(`/api/v1.0/indexcity/getjiakeCountyData`,params)
	},
	// 业务-有线装维（集客） 柱图数据
	getjikeCityInfo: params => {
		return get(`/api/v1.0/indexcity/getjikeCountyData`)
	},
	//满意度
	getMydData: params => {
		return get('/api/v1.0/indexcity/getMydData')
	},
	
	//集客装机运维信息
	getindexInfo: params => {
		return get('/api/v1.0/index/getindexInfo')
	},
	//业务规模趋势图
	getbusinessData: params => {
		return get('/api/v1.0/indexcity/getbusinessData')
	},
	//无线网络质量
	GetwxData: params => {
		return get('/api/v1.0/indexcity/GetwxData')
	},
	//---------------------------------详情明细------------------------------------
	//获取所有地市下拉框
	getcity: params => {
		return get('/api/v1.0/common/getcity')
	},
	//获取明细地市下拉框  
	getmxcity: params => {
		return getp(`/api/v1.0/common/getmxcity`,params)
	},
	//获取明细区县下拉框
	getmxcounty: params => {
		return getp(`/api/v1.0/common/getmxcounty`,params)
	},
	//获取区县统计数据
	getcountyData: params => {
		return getp(`/api/v1.0/common/getcountyData`,params)
	},
	//获取明细数据
	getdataInfo: params => {
		return getp(`/api/v1.0/common/getdataInfo`,params)
	},
	
	//---------------------------------春节总结------------------------------------
	//首页
	getjksyData: params => {
		return get(`/jkapi/v1.0/chunjie/getjksyData`, params)
	},
	//轮播图片
	getimageData: params => {
		return get(`/jkapi/v1.0/chunjie/getimageData`, params)
	},
	//漫游趋势
	gethxwmyqsData: params => {
		return get(`/jkapi/v1.0/chunjie/gethxwmyqsData`, params)
	},
	//漫游相关
	gethxwmyxgData: params => {
		return get(`/jkapi/v1.0/chunjie/gethxwmyxgData`, params)
	},
	//重保区域
	getwyzxzbqyData: params => {
		return get(`/jkapi/v1.0/chunjie/getwyzxzbqyData`, params)
	},
	// 互联网-CHBN业务保障情况-个人业务
	gethlwgrywData: params => {
		return get(`/jkapi/v1.0/chunjie/gethlwgrywData`, params)
	},
	// 网优中心-个人业务-手机上网
	getwyzxsjswData: params => {
		return get(`/jkapi/v1.0/chunjie/getwyzxsjswData`, params)
	},
	// 网优中心-个人业务-话务量
	getwyzxhwlData: params => {
		return get(`/jkapi/v1.0/chunjie/getwyzxhwlData`, params)
	},
	// 网优中心-个人业务-短信
	getwyzxdxData: params => {
		return get(`/jkapi/v1.0/chunjie/getwyzxdxData`, params)
	},
	//网优中心-个人业务趋势
	getwyzxgrywqsData: params => {
		return get(`/jkapi/v1.0/chunjie/getwyzxgrywqsData`, params)
	},
	// 互联网-CHBN业务保障情况-家庭业务
	gethlwjtywData: params => {
		return get(`/jkapi/v1.0/chunjie/gethlwjtywData`, params)
	},
	// 家客室-CHBN业务保障情况-家庭业务
	getjkschbnData: params => {
		return get(`/jkapi/v1.0/chunjie/getjkschbnData`, params)
	},
	// 家客室-在线峰值趋势
	getjkszxfzqsData: params => {
		return get(`/jkapi/v1.0/chunjie/getjkszxfzqsData`, params)
	},
	// 互联网-CHBN业务保障情况-家庭业务-CCTV1趋势
	gethlwcctvData: params => {
		return get(`/jkapi/v1.0/chunjie/gethlwcctvData`, params)
	},
	// 政企室
	getzqsData: params => {
		return get(`/jkapi/v1.0/chunjie/getzqsData`, params)
	},
	// 安全室
	getaqbData: params => {
		return get(`/jkapi/v1.0/chunjie/getaqbData`, params)
	},
	// 互联网-重要网络保障
	gethlwzywlData: params => {
		return get(`/jkapi/v1.0/chunjie/gethlwzywlData`, params)
	},
	// 新业务
	gethxwxywData: params => {
		return get(`/jkapi/v1.0/chunjie/gethxwxywData`, params)
	},
	// 核心网-流量（新增接口）
	gethxwllData: params => {
		return get(`/jkapi/v1.0/chunjie/gethxwllData`, params)
	},
	//引导
	getydywData: params => {
		return get(`/jkapi/v1.0/chunjie/getydywData`, params)
	},
	// IT支撑部
	getitzcbData: params => {
		return get(`/jkapi/v1.0/chunjie/getitzcbData`, params)
	},
	//手机用户数
	getsjyhsData: params => {
		return get(`/jkapi/v1.0/chunjie/getsjyhsData`, params)
	},
	//手机用户数日均
	getsjyhsrjData: params => {
		return get(`/jkapi/v1.0/chunjie/getsjyhsrjData`, params)
	},
	
	//---------------------------------春节日报------------------------------------
	// 互联网-质量
	gethlwzlData: params => {
		return get(`/jkapi/v1.0/ribao/gethlwzlData`, params)
	},
	// 互联网-业务量情况
	gethlwywlqkData: params => {
		return get(`/jkapi/v1.0/ribao/gethlwywlqkData`, params)
	},
	// 核心网-业务量情况
	gethxwywlqkData: params => {
		return get(`/jkapi/v1.0/ribao/gethxwywlqkData`, params)
	},
	// 用户数情况
	gethxwyhsqkData: params => {
		return get(`/jkapi/v1.0/ribao/gethxwyhsqkData`, params)
	},
	// 用户数情况-互联网
	gethlwyhsqkData: params => {
		return get(`/jkapi/v1.0/ribao/gethlwyhsqkData`, params)
	},
	// 监控-首页
	getjksyDataRb: params => {
		return get(`/jkapi/v1.0/ribao/getjksyData`, params)
	},
	//漫游趋势
	getmyqsData: params => {
		return get(`/jkapi/v1.0/ribao/getmyqsData`, params)
	},
	//漫游相关
	getmyxgData: params => {
		return get(`/jkapi/v1.0/ribao/getmyxgData`, params)
	},
	//重保区域
	getwyzxZbqyData: params => {
		return get(`/jkapi/v1.0/ribao/getwyzxZbqyData`, params)
	},
	//广电业务
	getgdywData: params => {
		return get(`/api/v1.0/index/getgdywData`, params)
	},
	//广电业务
	getgdywcityData: params => {
		return getp(`/api/v1.0/index/getgdywcityData`, params)
	}
};
